package com.example.controller;

import com.example.ext.entity.ExtSystemRole;
import com.example.service.SystemRoleService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * Created by simon on 2017/9/10.
 */
@RestController
public class RoleController {

    @Autowired
    private SystemRoleService roleService;

    @ApiOperation(value = "查询角色列表",notes = "查询角色列表")
    @RequestMapping(value="/api/role/queryList",method = RequestMethod.POST)
    Map<String,Object> queryList(@RequestBody ExtSystemRole extRole) {

        return roleService.queryList(extRole);
    }

    @ApiOperation(value = "查询角色列表",notes = "查询角色列表")
    @RequestMapping(value="/api/role/queryListAll",method = RequestMethod.POST)
    Map<String,Object> queryListAll(@RequestBody ExtSystemRole extRole) {

        return roleService.queryListAll(extRole);
    }

    @ApiOperation(value = "添加角色列表",notes = "添加角色列表")
    @RequestMapping(value="/api/role/add",method = RequestMethod.POST)
    Map<String,Object> add(@RequestBody ExtSystemRole extRole) {

        return roleService.add(extRole);
    }

    @ApiOperation(value = "更新角色列表",notes = "更新角色列表")
    @RequestMapping(value="/api/role/update",method = RequestMethod.POST)
    Map<String,Object> update(@RequestBody ExtSystemRole extRole) {

        return roleService.update(extRole);
    }


    @ApiOperation(value = "查询角色详细信息",notes = "查询角色详细信息")
    @RequestMapping(value="/api/role/findById/{id}",method = RequestMethod.POST)
    Map<String,Object> findById(@PathVariable String id) {

        return roleService.queryById(id);
    }

    @ApiOperation(value = "删除角色",notes = "删除角色")
    @RequestMapping(value="/api/role/deleteByIdList",method = RequestMethod.POST)
    Map<String,Object> deleteByIdList(@RequestBody Map<String,Object> param) {
        List<String> ids = (List<String>) param.get("ids");
        return roleService.deleteById(ids);
    }


    @ApiOperation(value = "查询机构下面的角色",notes = "查询机构下面的角色")
    @RequestMapping(value="/api/role/findByOwnerOrgList/{id}",method = RequestMethod.POST)
    Map<String,Object> findByOwnerOrgList(@PathVariable String id) {
        return roleService.findByOwnerOrgList(id);
    }

    @ApiOperation(value = "查询角色类型下的角色",notes = "查询角色类型下的角色")
    @RequestMapping(value="register/queryByRoleTypeId/{id}",method = RequestMethod.POST)
    public Map<String, Object> queryByRoleTypeId(@PathVariable String id){
        return roleService.queryByRoleTypeId(id);
    }


    @ApiOperation(value = "查询机构类型下的角色",notes = "查询机构类型下的角色")
    @RequestMapping(value="register/queryByPartyTypeList/{id}",method = RequestMethod.POST)
    public Map<String, Object> queryByPartyTypeList(@PathVariable String id){
        return roleService.queryByPartyTypeList(id);
    }

}
